package com.ht.common.core.enums;

import com.ht.common.core.annotation.EnumDictType;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author：hdengxian
 * @Date：2023/12/20 16:07
 */
@EnumDictType(dictName = "是否", dictType = "yes_or_no")
public enum YesOrNoEnum {
    NO_0("0", "否"),
    YES_1("1", "是"),
    ;
    private String code;
    private String name;

    YesOrNoEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static List<Map<String, String>> getDictList() {
        return Arrays.asList(values()).stream().map(y->{
            Map<String, String> map = new HashMap<>();
            map.put("code", y.getCode());
            map.put("name", y.getName());
            return map;
        }).collect(Collectors.toList());
    }
}
